package br.com.infnet.action;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.infnet.cultbook.dao.IGenericDao;
import br.com.infnet.cultbook.domain.ItemPedido;
import br.com.infnet.cultbook.domain.Livro;
import br.com.infnet.cultbook.domain.Pedido;
import br.com.infnet.cultbook.domain.Cliente;

/**
 * Servlet implementation class Teste
 */
public class Teste extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	@EJB
	private IGenericDao genericDao;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Teste() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doExecute(request, response);
	}

	/**
	 * @param request
	 * @param response
	 * @throws IOException 
	 */
	private void doExecute(HttpServletRequest request,
			HttpServletResponse response) throws IOException {
		genericDao.listar(Cliente.class);
		genericDao.listar(Pedido.class);
		genericDao.listar(ItemPedido.class);
		genericDao.listar(Livro.class);
		response.getWriter().print("foi!");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doExecute(request, response);
	}

}
